package com.mnb.base.service.impl;

import com.mnb.base.entity.StZvarlB;
import com.mnb.common.utils.R;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import com.mnb.base.entity.StZvarlB;
import com.mnb.base.mapper.StZvarlBMapper;
import com.mnb.base.service.StZvarlBService;

@Service
public class StZvarlBServiceImpl implements StZvarlBService {

    @Resource
    private StZvarlBMapper stZvarlBMapper;


    @Override
    public R getList(StZvarlB stZvarlB) {
        List<StZvarlB> list = stZvarlBMapper.getList(stZvarlB);
        return R.ok(list);
    }

    @Override
    public R getMstmList(StZvarlB stZvarlB) {
        List<StZvarlB> list = stZvarlBMapper.getMstmList(stZvarlB);
        return R.ok(list);
    }

    @Override
    public int deleteByPrimaryKey(String stcd, Date mstm, Short ptno) {
        return stZvarlBMapper.deleteByPrimaryKey(stcd, mstm, ptno);
    }

    @Override
    public R insert(StZvarlB stZvarlB) {
        StZvarlB count = stZvarlBMapper.selectByPrimaryKey(stZvarlB.getStcd(), stZvarlB.getMstm(), stZvarlB.getPtno());
        if(count != null){
            return R.fail("该信息已存在");
        }
        stZvarlBMapper.insert(stZvarlB);
        return R.ok();
    }

    @Override
    public R udpate(StZvarlB stZvarlB) {
        stZvarlBMapper.updateByPrimaryKey(stZvarlB);
        return R.ok();
    }

}
